package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.RepairProduct;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RepairProductDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "报价的产品id")
    private Integer productId;

    @ApiModelProperty(value = "维修单id")
    private Integer repairId;

    @ApiModelProperty(value = "退货数量")
    private Integer num;

    @ApiModelProperty(value = "维修数量")
    private Integer rejectNum;

    @ApiModelProperty(value = "已发货数量")
    private Integer deliverNum;

    @ApiModelProperty(value = "实际维修数量")
    private Integer rejectRealityNum;

    @ApiModelProperty(value = "维修状态：0未完成，1已维修")
    private Integer status;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "规格型号")
    private String specification;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "计量单位")
    private String unitName;

    @ApiModelProperty(value = "材质")
    private String material;

    @ApiModelProperty(value = "产品名称")
    private String name;


    public RepairProductDTO() {}

    public RepairProductDTO(RepairProduct entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static RepairProductDTO convert(RepairProduct entity) {
        return new RepairProductDTO(entity);
    }

    public static List<RepairProductDTO> convertList(List<RepairProduct> list) {
        List<RepairProductDTO> resultList = new ArrayList<>();
        for (RepairProduct entity : list) {
            resultList.add(new RepairProductDTO(entity));
        }
        return resultList;
    }}
